from sklearn.preprocessing import StandardScaler
import pandas as pd

data = {'Feature1': [1.0, 2.0, 3.0, 4.0, 5.0],
        'Feature2': [100, 150, 200, 250, 299]}

df = pd.DataFrame(data)
print(df)

# 标准化
scaler = StandardScaler()
df_scaled = pd.DataFrame(scaler.fit_transform(df), columns=df.columns)
print(df_scaled)

# 归一化
df_normalized = (df - df.min()) / (df.max() - df.min())
print(df_normalized)

data2 = {'Age': [18, 22, 25, 30, 35, 40, 50, 60, 70, 80]}
df2 = pd.DataFrame(data2)

# 将Age分为3个区间
df2['Age_Group'] = pd.cut(df2['Age'], bins=3, labels=["Young", "Middle-aged", "Old"])
print(df2)